package com.websocet.controller;

import cn.hutool.core.util.CharsetUtil;
import cn.hutool.core.util.HexUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.websocet.domain.BaseResponse;
import com.websocet.domain.SysUser;
import com.websocet.enums.ifElse;
import com.websocet.service.A;
import com.websocet.service.SysUserService;
import com.websocet.service.impl.SysUserServiceImpl;
import org.apache.tomcat.util.buf.HexUtils;
import org.omg.Messaging.SYNC_WITH_TRANSPORT;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;
import java.util.Optional;

/**
 * @Author: 陈玉鹏
 * @Description: TODO
 * @DateTime: 2023/6/18 22:54
 */
@RestController
public class AController {


    @Qualifier("a3")
    @Autowired
    A a;

    @GetMapping("/aaa")
    public String getA() {
        return a.get();
    }
    @GetMapping("/testmvc/{id}")
    public Integer getB(@PathVariable("id") Integer id ) {
        return id;
    }
    @GetMapping("/testmvcQuery")
    public String getC(@RequestParam String id ) {
        return id;
    }
    @GetMapping("/entrySysUser")
    public SysUser getD() {
        SysUser sysUser = new SysUser();
        sysUser.setUserName("1223");
        return sysUser;
    }

    @GetMapping("/entrydate")
    public BaseResponse getentrydate() {

        return BaseResponse.ok("123");
    }

//    public static void main(String[] args) {
//        SysUser sysUser = new SysUser();
//        System.out.println(sysUser == null);
//        System.out.println(ObjectUtils.isEmpty(sysUser));
//        System.out.println(ObjectUtils.isNull(sysUser));
//        System.out.println(Optional.ofNullable(sysUser).isPresent());
//        System.out.println(null == sysUser.getAvatar());
//        SysUser sysUser1 = null;
//        System.out.println(sysUser1.getSex());
//    }

    @Autowired
    SysUserService sysUserService;

    @PostMapping("/fds")
    public SysUser getss(@RequestBody SysUser sysUser) {
        LambdaQueryWrapper<SysUser> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(StringUtils.isNotBlank(sysUser.getDeptId()),SysUser::getDeptId, sysUser.getDeptId());
        return sysUserService.getOne(queryWrapper);

    }
}
